package com.itheima.reggie.mapper;

import com.itheima.reggie.entity.ShoppingCart;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface ShoppingCartMapping {

    //查询购物车中当前菜品dishId或 套餐的setmealId 购物车数据
    ShoppingCart findByShoppingCart(ShoppingCart shoppingCart);


    //更新指定购物车菜数据数量 或者购物车主键更新数量
    @Update("update shopping_cart set number=#{number} where id=#{id}")
    Integer updateNumber(@Param("id") Long id, @Param("number") Integer number);


    //插入新的一条购物车数据
    @Insert("insert into shopping_cart values(null,#{name},#{image},#{userId},#{dishId},"+
    "#{setmealId},#{dishFlavor},#{number},#{amount},#{createTime})")
    Integer save(ShoppingCart shoppingCart);

    //查询指定用户的购物车集合数据
    @Select("select * from shopping_cart where user_id=#{userId}")
    List<ShoppingCart> findAllByUserId(Long Userid);


    //删除指定用户的购物车数据
    @Delete("delete from shopping_cart where user_id=#{userId}")
    Integer deleteByUserId(Long userId);


    Integer deleteByUidDid(ShoppingCart shoppingCart);


    @Select("select * from shopping_cart where dish_id=#{id}")
    ShoppingCart selectByDishId(Long id);

    ShoppingCart selectById(ShoppingCart shoppingCart);



}
